<include file="Public/header" />
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>商铺管理</h3>
      <ul class="tab-base">
        <li><a href="{:U('Store/storelist',array('op'=>'list'))}" ><span>管理</span></a></li>
		<li><a href="javascript:void(0);" class="current"><span>创建</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form id="add_form" method="post" action="{:U('Store/storelist',array('op'=>'add'))}">
    <table class="table tb-type2 nobdb">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="store_name">商铺名称:</label></td>
        </tr>    
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" id="store_name" name="store_name" class="txt"></td>
        </tr>          
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="account">登录账号:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" id="account" name="account" class="txt"></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label class="validation" for="pwd">登录密码:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="password" id="pwd" name="pwd" class="txt"></td>
        </tr>
      </tbody>
      <tfoot>
        <tr class="tfoot">
          <td colspan="2"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span>保存</span></a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script>
//按钮先执行验证再提交表
$(function(){
	$("#submitBtn").click(function(){
	    if($("#add_form").valid()){
	     $("#add_form").submit();
		}
	});
});

$(document).ready(function(){
	$("#add_form").validate({
		errorPlacement: function(error, element){
			error.appendTo(element.parent().parent().prev().find('td:first'));
        },
        success: function(label){
            label.addClass('valid');
        },
        rules : {
        	store_name : {
                required : true,
				remote	: {
					url : AdminUrl+'?c=Store&a=storecheck',
                    type:'get',
                    data:{
                    	store_name : function(){
                            return $('#store_name').val();
                        }
                    }
                }
            },			
        	account : {
                required : true,
				remote	: {
					url : AdminUrl+'?c=Store&a=storecheck',
                    type:'get',
                    data:{
                    	account : function(){
                            return $('#account').val();
                        }
                    }
                }
            },
            pwd : {
                required : true
            }
        },
        messages : {
        	store_name : {
                required : '请输入名称',
                remote : '此名称已存在'
            },			
        	account : {
                required : '请输入账号',
                remote : '此账号已存在'
            },
            pwd : {
                required : '请输入密码'
            }
        }
	});
});
</script> 
<include file="Public/footer" />